import axios from '@/utils/request';

/**
 * 新增调拨单
 */
export async function AddSwaporder(params) {
    const res = await axios.post('/Swaporder/AddSwaporder',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}


/**
 * 更新调拨单
 */
export async function UpdateSwaporder(params) {
    const res = await axios.post('/Swaporder/UpdateSwaporder',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 获取调拨单查询分页列表
 */
 export async function QuerySwaporderByCondition(params) {
    const res = await axios.post('/Swaporder/QuerySwaporderByCondition',params);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 调拨单审核
 */
export async function AuitSwaporder(params) {
    const res = await axios.post('/Swaporder/AuitSwaporder',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 调拨单反审核
 */
export async function AnitSwaporder(id) {
    const res = await axios.post('/Swaporder/AnitSwaporder?id='+id);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 根据id获取调拨单
 */
 export async function QuerySwaporderById(id) {
    const res = await axios.get('/Swaporder/QuerySwaporderById/'+id);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 作废调拨单
 */
export async function DeleteSwaporder(id) {
    const res = await axios.post('/Swaporder/DeleteSwaporder?id='+id);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}




